package clsr.info.blog.service;

import clsr.info.blog.common.api.ITagService;
import clsr.info.blog.common.entity.Tag;
import clsr.info.blog.repository.TagRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class TagServiceImpl extends BaseServiceImpl<Tag> implements ITagService {

  @Autowired private TagRepository tagRepository;

  @Override
  public List<Tag> loadTags(Integer userId, Integer classifyId) {
    log.debug("loadTags userId is:{},classifyId is:{}", userId, classifyId);
    Tag tag = new Tag();
    tag.setClassifyId(classifyId);
    tag.setCreateUserId(userId);
    List<Tag> tagList = tagRepository.findAll(Example.of(tag));
    return tagList;
  }
}
